const routerView = `<transition name="fade-transform" mode="out-in"><router-view></router-view></transition>`;

import clone from "@/common/clone.js"


export default function (list) {
    return setComponent(clone(list))
}

function setComponent (list) {
    return list.map(item => {
        // 过滤按钮
        item.children?.[0] && (
            item.children = item.children.filter(temp => {
                return temp.isButton !== true
            })
        )
        if (item.children?.[0]) {
            item.component = {
                render: (e) => e({
                    template: routerView
                })
            }
            item.children = setComponent(item.children)
        }
        return Object.assign({ component: () => import(/* webpackChunkName: "view-[request]" */ `@/views${item.path}/index.vue`) }, item)
    })
}

